﻿<navigation:Page 
           xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
           xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
           xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
           xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
           xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation" 
           xmlns:Controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Toolkit" 
           xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions" 
           xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity" 
           xmlns:Micro="clr-namespace:Caliburn.Micro;assembly=Caliburn.Micro" 
           x:Class="OI.Views.ShellView"
           mc:Ignorable="d"
           d:DesignWidth="950" d:DesignHeight="700"
           Title="OI Catalog">

    <Controls:BusyIndicator x:Name="IsBusy">
        <Controls:BusyIndicator.BusyContent>
            <TextBlock Text="{Binding BusyContent}" />
        </Controls:BusyIndicator.BusyContent>

        <Grid x:Name="LayoutRoot" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="6" />
                <RowDefinition Height="*" />
            </Grid.RowDefinitions>

            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>

            <Grid Margin="0,8,0,0" Grid.Row="0">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>

                <Rectangle Grid.Column="0" Height="64" Width="24" Fill="{StaticResource ThemeColorBrush}" />

                <!--BACK BUTTON-->
                <Button x:Name="GoBack" Grid.Column="1" Margin="16,0,0,0" Height="40" Width="40"
                            VerticalAlignment="Top" Style="{StaticResource MetroArrowButtonStyle}"/>

                <!--LOGO IMAGE-->
                <Image Grid.Column="2"  Height="64" Source="{Binding LogoUri}" Margin="16,0,0,0" VerticalAlignment="Bottom"/>

                <!--MENU + TITLE-->
                <StackPanel Grid.Column="3" Margin="16,0,0,0" VerticalAlignment="Top">

                    <TextBlock Name="CustomerTitleBlock" Style="{StaticResource CustomerTitle}" />

                    <ItemsControl Name="MainMenu" Margin="-5,-6,0,0">
                        <ItemsControl.ItemTemplate>
                            <DataTemplate>
                                <Grid Visibility="{Binding EnabledVisibility}">
                                    <RadioButton Name="selRB"
                                                     Style="{StaticResource MenuRadioButton}"
                                                     GroupName="MainMenuGroup" 
                                                     IsChecked="{Binding IsSelected, Mode=TwoWay}"
                                                     Width="{Binding Width}"
                                                     Micro:Message.Attach="[Event Checked] = [Action MenuSelect($dataContext);]">
                                        <RadioButton.Content>
                                            <Grid>
                                                <TextBlock Name="mmText" Text="{Binding Header}"
                                                           VerticalAlignment="Top"
                                                           HorizontalAlignment="Left" 
                                                           Style="{StaticResource MainMenuItem}"
                                                           Width="Auto"/>
                                            </Grid>
                                        </RadioButton.Content>
                                    </RadioButton>

                                    <!--highlight-->
                                    <TextBlock Name="hl" Text="{Binding Header}"
                                                           VerticalAlignment="Top"
                                                           HorizontalAlignment="Left"
                                                           Margin="4,1,0,0"
                                                           Style="{StaticResource MainMenuItem}"
                                                           Foreground="Transparent"
                                                           Width="Auto">
                                            <TextBlock.Resources>
                                                <Storyboard x:Key="HLOFF">
                                                    <ColorAnimation Storyboard.TargetName="hl" Storyboard.TargetProperty="(TextBlock.Foreground).(SolidColorBrush.Color)" Duration="0" To="Transparent"/>
                                                </Storyboard>
                                                <Storyboard x:Key="HLON">
                                                    <ColorAnimation Storyboard.TargetName="hl" Storyboard.TargetProperty="(TextBlock.Foreground).(SolidColorBrush.Color)" Duration="0" To="#40000000"/>
                                                </Storyboard>
                                            </TextBlock.Resources>
                                        
                                            <i:Interaction.Triggers>
                                                <i:EventTrigger EventName="MouseEnter">
                                                    <ei:ControlStoryboardAction Storyboard="{StaticResource HLON}"/>
                                                </i:EventTrigger>
                                                <i:EventTrigger EventName="MouseLeave">
                                                    <ei:ControlStoryboardAction Storyboard="{StaticResource HLOFF}"/>
                                                </i:EventTrigger>
                                                 <i:EventTrigger EventName="MouseLeftButtonDown">
                                                    <ei:ChangePropertyAction TargetName="selRB" PropertyName="IsChecked" Value="True" />
                                                </i:EventTrigger>
                                            </i:Interaction.Triggers>
                                    </TextBlock>
                                </Grid>
                            </DataTemplate>
                        </ItemsControl.ItemTemplate>

                        <ItemsControl.ItemsPanel>
                            <ItemsPanelTemplate>
                                <Controls:WrapPanel Orientation="Horizontal" />
                            </ItemsPanelTemplate>
                        </ItemsControl.ItemsPanel>

                    </ItemsControl>
                </StackPanel>

                <!--TOP RIGHT-->
                <ContentControl Grid.Column="4" Name="TopRight" Margin="24,0,12,0" VerticalAlignment="Center" HorizontalAlignment="Right"/>

            </Grid>

            <!--SEP-->
            <Grid Grid.Row="1" Background="#08000000" Margin="24,2,24,2"/>

            <!--MAIN CONTENT-->
            <ContentControl Name="ActiveItem" Grid.Row="2"
                                HorizontalAlignment="Stretch"
                                VerticalAlignment="Stretch"
                                HorizontalContentAlignment="Stretch"  
                                VerticalContentAlignment="Stretch" />

            <ContentControl Name="MessageBox" Grid.RowSpan="3" HorizontalAlignment="Center" VerticalAlignment="Center" />

        </Grid>

    </Controls:BusyIndicator>

</navigation:Page>

